#ifdef DATA_UTILS_C
#define DATA_UTILS_C

#include <stdint.h>
/*!@brief convert to the i386 floating point representation
 *
 *@param in The number to be converted
 *
 * This function is nasty. The rotomotion docs specify that all doubles are
 * to be sent as they appear in i386 memory. That format is ieee double
 * persison format with the upper and lower 32-bits swaped.
 *    This uses uint64_t which should be defined in stdint.h.
 * The actual switching is done with unions and is pretty nasty.
 */
uint64_t static htonf(double in) {

    union { 
        double d;
        uint32_t i[2];
        uint64_t l;
    } temp;

    temp.d = in;

#ifdef __i386__
   uint32_t holder = temp.i[0];
   temp.i[0] = temp.i[1];
   temp.i[1] = holder;
#endif

   return temp.l;

} //end htonf

double static ntohf(uint64_t in) {

    union {
        double d;
        uint32_t i[2];
        uint64_t l;
    } temp;

    temp.l = in;

#ifdef __i386__
    uint32_t holder = temp.i[0];
    temp.i[0] = temp.i[1];
    temp.i[1] = holder;
#endif

    return temp.d;
} //end ntohf

#endif
